package com.me.pikachu.main;

import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class DrawObject {

	private SpriteBatch batch;

	private MatrixTransformScreen transferMatrix;

	private MatrixProcess processMatrix;

	private int[][] matrix;

	public DrawObject(SpriteBatch batch, OrthographicCamera camera,
			MatrixTransformScreen transferMatrix, MatrixProcess processMatrix) {

		this.batch = batch;
		this.transferMatrix = transferMatrix;
		this.processMatrix = processMatrix;
		matrix = processMatrix.getOrigialMatrix();
	}

	public void changeOriginalMatrix(){
		matrix = processMatrix.getOrigialMatrix();
	}
	
	public void draw() {
		batch.begin();
		for (int i = 0; i < transferMatrix.getVerticalElement(); i++) {
			for (int j = 0; j < transferMatrix.getHorizonElement(); j++) {
				Point p = transferMatrix.Point2Screen(i, j);

				if (matrix[i][j] != Point.COMPARE) {
					batch.draw(Asset.squares.get(0), p.getScreenI(),
							p.getScreenJ(), transferMatrix.getWeightElement(),
							transferMatrix.getHeightElement());
					batch.draw(Asset.pokemon.get(matrix[i][j]), p.getScreenI(),
							p.getScreenJ(), transferMatrix.getWeightElement(),
							transferMatrix.getHeightElement());
				}
			}
		}
		batch.end();
	}
}
